package study01;


public class Java13_DG {
    public static void main(String[] args) {
        DG d = new DG();
        int a = d.sum(1, 1, 18);
        System.out.println(a);
        System.out.println(computedDC(18));
        System.out.println(computedJC(5));
    }

    public static int computedDC(int num) {
        num = num % 2 == 0 ? num - 1 : num;
        if (num <= 1) {
            return 1;
        } else {
            return num + computedDC(num - 2);
        }
    }

    //    阶乘   5!  =>  5*4*3*2*1
    //    0 的阶乘为 1
    public static int computedJC(int num) {
        if (num == 0) {
            return 1;
        } else {
            return num * computedJC(num - 1);
        }
    }
}

class DG {
    private String name = "zs";
    int sum (int first_num, int result, int num) {
        System.out.println(name);
        int temp_num = first_num + 2;
        int res = result + temp_num;
        if (temp_num > num) {
            return result;
        } else {
            return sum(temp_num, res, num);
        }
    }
}